import React, {Component} from 'react';
import {Popup, Tab,Button,Group,Field ,Dialog } from 'saltui';
import Icon from 'salt-icon';
import ToastSuccess from 'salt-icon/lib/ToastSuccess';
import RManagedetail from '../form/detail/RManagedetail';
import RHandledetail from '../form/detail/RHandledetail';

/**
 *  <RoomList  onClick  room >
 */
export default class RoomList extends React.Component {
  constructor(props) {

    super(props);
    this.state = {
      prices :[]
    };
    this.state.room = this.props.room
    this.state.onClick = this.props.onClick


  }

  onClick = (id,event) =>{
    this.state.onClick(id,event);
  }


  render() {

    return   <ul>
      {
        this.props.room.map((room,index) =>
          <li>
            <div className ="room-list-left">
              <ToastSuccess width='20'  onClick={(e) => this.onClick(index,e)}  height='20' fill={room.selected ? 'red' : '#cccccc' }  className="input" />
            </div>
            { this.props.roomtype ==1 ?  <RManagedetail  typeid={this.props.typeid} onChange={this.props.onChange} option={this.props.option} room={room}  /> :
              <RHandledetail
                findRoom={this.props.findRoom} changeRoom={this.props.changeRoom}   isExChange={this.props.isExChange}
                             selectToRoom={this.props.selectToRoom} exChange ={this.props.exChange}  typeid={this.props.typeid}
                             onChange={this.props.onChange} option={this.props.option} room={room}/>}
                             
          </li>
        )
      }
    </ul>
  }
}
